/**
 * File Name : AndroidInput.java
 * <p>
 * Author : maidou
 * <p>
 * Create Time : 2012-11-15, 下午10:58:16
 * <p>
 */

package com.ttomato.game.framework.impl;

import java.util.List;

import android.content.Context;
import android.os.Build.VERSION;
import android.view.View;

import com.ttomato.game.framework.Input;

/**
 * Add the description for the file here.
 * <p>
 */
public class AndroidInput implements Input
{
    AccelerometerHandler mAccelerometerHandler;
    
    KeyboardHandler mKeyboardHandler;
    
    TouchHandler mTouchHandler;
    
    public AndroidInput(Context context, View view, float scaleX, float scaleY)
    {
        mAccelerometerHandler = new AccelerometerHandler(context);
        
        mKeyboardHandler = new KeyboardHandler(view);
        
        if (Integer.parseInt(VERSION.SDK) < 5)
        {
            mTouchHandler = new SingleTouchHandler(view, scaleX, scaleY);
        }
        else
        {
            mTouchHandler = new MultiTouchHandler(view, scaleX, scaleY);
        }
    }
    
    @Override
    public boolean isKeyPressed(int keyCode)
    {
        return mKeyboardHandler.isKeyPressed(keyCode);
    }
    
    @Override
    public boolean isTouchDown(int pointer)
    {
        return mTouchHandler.isTouchDown(pointer);
    }
    
    @Override
    public int getTouchX(int pointer)
    {
        return mTouchHandler.getTouchX(pointer);
    }
    
    @Override
    public int getTouchY(int pointer)
    {
        return mTouchHandler.getTouchX(pointer);
    }
    
    @Override
    public float getAccelX()
    {
        return mAccelerometerHandler.getAccelX();
    }
    
    @Override
    public float getAccelY()
    {
        return mAccelerometerHandler.getAccelY();
    }
    
    @Override
    public float getAccelZ()
    {
        return mAccelerometerHandler.getAccelZ();
    }
    
    @Override
    public List<KeyEvent> getKeyEvents()
    {
        return mKeyboardHandler.getKeyEvents();
    }
    
    @Override
    public List<TouchEvent> getTouchEvents()
    {
        return mTouchHandler.getTouchEvents();
    }
}
